home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
276-300
/
294
/
dnet
/
amiga
/
lib
/
dwrite.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-14
|
1KB
|
59 lines
/*
* DWrite.c
*/
#include "lib.h"
long
DQueueFull(_chan)
void *_chan;
{
CHANN *chan = (CHANN *)_chan;
return (chan->qlen && (chan->queued > chan->qlen));
}
long
DWrite(_chan, _buf, bytes)
void *_chan;
void *_buf;
long bytes;
{
int error = bytes;
CHANN *chan = (CHANN *)_chan;
char *buf = (char *)_buf;
if (chan->qlen) {
if (WaitQueue(chan, NULL) >= 0) {
IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_CLEAR|MEMF_PUBLIC);
ior->io_Command = DNCMD_WRITE;
ior->io_Unit = (void *)chan->chan;
ior->io_Offset = (long)chan;
ior->io_Message.mn_ReplyPort = (PORT *)chan;
ior->io_Data = AllocMem(bytes, MEMF_PUBLIC);
ior->io_Length = bytes;
BMov(buf, ior->io_Data, bytes);
PutMsg(chan->dnetport, (MSG *)ior);
++chan->queued;
} else {
error = -1;
}
} else {
IOSTD ior;
ior.io_Command = DNCMD_WRITE;
ior.io_Unit = (void *)chan->chan;
ior.io_Offset = (long)chan;
ior.io_Message.mn_ReplyPort = (PORT *)chan;
ior.io_Data = (APTR)buf;
ior.io_Length = bytes;
PutMsg(chan->dnetport, (MSG *)&ior);
WaitMsg(&ior);
if (ior.io_Error)
error = -1;
}
FixSignal(chan);
return(error);
}